<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class IndexController extends Controller
{
    public function index()
    {
       return view('home.index');
    }
    public function my_island(){
        $limit = 10;
        $list = DB::table('bt_my_island')->paginate($limit);//dd($list);die;
        $html = '';
        $html .= '<div style="with:100%;height:20px;margin-top:10px;">
        <ul class="page">';
        if($list->currentPage() != 1){
            $nextpage = $list->currentPage() - 1;
            $html .= '<li><a href="my_island?page='.$nextpage.'">上一页</a></li>';
        }
        for($i=1;$i<=$list->lastPage();$i++){
            $html .= '<li><a href="my_island?page='.$i.'">'.$i.'</li></a>';
        }   
        if($list->lastPage() != $list->currentPage()){
            $lastpage = $list->currentPage() + 1;
            $html .= '<li><a href="my_island?page='.$lastpage.'">下一页</a></li>';
        }
        $html .= '</ul>';
        $html .= '</div>';
        return view("home.my_island",['page'=>$html,'list'=>$list->items()]);
    }
}
